<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>modal</title>
</head>

<body">
  <style>
    * {
      padding: 0px;
      margin: 0px;
    }

    body {
      background-color: #f5f5f5;
      width: 100%;
      height: 100%;
    }

    .modal {
      position: absolute;
      display: none;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }

    .modal-inner {
      padding: 32px;
      width: 200px;
      height: 200px;
      background-color: #ffffff;
      box-shadow: 1px 1px 50px rgba(0, 0, 0, .3);
      border-radius: 5px;
    }

    .bounce-enter-active {
      animation: bounce-in .5s;
    }

    .bounce-leave-active {
      animation: bounce-out .5s;
    }

    @keyframes bounce-in {
      0% {
        opacity: 0;
        transform: scale(0);
      }

      100% {
        opacity: 1;
        transform: scale(1);
      }
    }

    @keyframes bounce-out {
      0% {
        opacity: 1;
        transform: scale(1);
      }

      100% {
        opacity: 0;
        transform: scale(0);
      }
    }
  </style>

  <div class="modal" id="modal">
    <div class="modal-inner bounce-enter-active" id="modal-inner">
      测试
    </div>
  </div>

  <button onclick="show()">弹窗</button>
  <button onclick="leave()">离开</button>

  <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
  <script>
    function show() {
      $('#modal').css('display', 'block');
    }
    function leave() {
      $('#modal-inner').removeClass('bounce-enter-active');
      $('#modal-inner').addClass('bounce-leave-active');
      setTimeout(() => {
        $('#modal-inner').remove();
      }, 0.3 * 1000);

    }
  </script>
  </body>

</html>
